﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.Xml.XPath;
using Zeus.Thunder.Core;

namespace SharpTrainer.Xml
{
    class XPathTest : ITestCase
    {
        public void Run()
        {
            string baseDir = AppDomain.CurrentDomain.BaseDirectory;
            int index = baseDir.IndexOf("bin");
            string path = baseDir.Substring(0, index) + "Xml/customers.xml";
            
            XmlDocument doc = new XmlDocument();
            doc.Load(path);
            XmlNode n = doc.SelectSingleNode("customers/customer[firstname='Thomas']");
            Console.WriteLine(n.InnerText);

            Console.WriteLine("*********************************");

            XPathDocument doc2 = new XPathDocument(path);
            XPathNavigator nav = doc2.CreateNavigator();
            foreach (XPathNavigator a in nav.Select ("customers/customer/firstname"))
                Console.WriteLine(a.Value);

        }
    }
}


